package com.onlookers.server;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class SubServlet extends HttpServlet{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		resp.setContentType("text/plain");
		resp.getWriter().println("Hello BAE World!");
		
		String title = req.getParameter("title");
		String date = req.getParameter("date");
		String email = req.getParameter("email");
		String phone = req.getParameter("phone");
		if (title == null || date == null || (email == null && phone == null)) {
			resp.getWriter().println("Argruments Error");
			return;
		}
		User user = new User(req.getParameter("title"),
				req.getParameter("date"),
				req.getParameter("email"),
				req.getParameter("phone"));
		EventService service = EventService.INSTANCE;
		service.addUserSub(user);
	}
	

}
